//
//  Animation.m
//  UI_Day02_homework
//
//  Created by aaaaaa on 16/6/4.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Animation.h"

@implementation Animation

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

+ (instancetype)animationWithImageName:(NSString *)imageName withImageFormat:(NSString *)imageForme withStartCount:(NSInteger)startCount withImageCount:(NSInteger)imageCount withImageFrame:(CGRect)frame{
    NSMutableArray<UIImage *> *array = [NSMutableArray arrayWithCapacity:0];
    for (NSInteger i = 0; i < imageCount ; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%@%ld.%@", imageName, i + startCount , imageForme]];
        [array addObject:image];
        [image release];
    }
    Animation *imageView = [[Animation alloc] init];
    imageView.frame = frame;
    imageView.animationImages = array;
    imageView.animationRepeatCount = 0;
    imageView.animationDuration = imageCount  * 0.1;
    [imageView startAnimating];
    return [imageView autorelease];
}

@end
